package com.stone.serverless.server;


import com.stone.serverless.core.classloader.JarLoadServiceImpl;
import com.stone.serverless.rumtime.spring.SpringContainerRuntime;
import com.stone.serverless.sdk.rumtime.ContainerRuntime;
import com.stone.serverless.sdk.loader.JarLoadService;
import com.stone.serverless.sdk.enums.RuntimeTypeEnum;

/**
 * @author MECHREVO
 */
public class StoneServerlessServer {
    static Object LOCK = new Object();

    public static void main(String[] args) throws InterruptedException {
        String[] jars = new String[]{
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-test1\\target\\stone-serverless-test1-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-datasource\\stone-serverless-datasource-biz\\target\\stone-serverless-datasource-biz-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-orm\\stone-serverless-orm-mybatis\\target\\stone-serverless-orm-mybatis-component.jar",
                "D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-web\\stone-serverless-web-spring-tomcat\\target\\stone-serverless-web-spring-tomcat-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-orm\\stone-serverless-orm-beetl\\target\\stone-serverless-orm-beetl-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-web\\stone-serverless-web-spring-jetty\\target\\stone-serverless-web-spring-jetty-component.jar",
                "D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-test2\\stone-serverless-test2-biz\\target\\stone-serverless-test2-biz-component.jar",
                "D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-dashboard\\target\\stone-serverless-dashboard-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-registry-center\\stone-serverless-registry-nacos\\target\\stone-serverless-registry-nacos-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-rpc\\stone-serverless-rpc-okhttp\\target\\stone-serverless-rpc-okhttp-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-config-center\\stone-serverless-config-nacos\\target\\stone-serverless-config-nacos-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-auth\\stone-serverless-auth-satoken\\target\\stone-serverless-auth-satoken-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-cache\\stone-serverless-cache-redis\\target\\stone-serverless-cache-redis-component.jar",
                //"D:\\work\\stone-serverless\\stone-serverless-component\\stone-serverless-event-center\\stone-serverless-event-biz\\target\\stone-serverless-event-biz-component.jar",

        };
        Long startTime = System.currentTimeMillis();
        //初始化一个运行环境为spring
        ContainerRuntime.put(RuntimeTypeEnum.SPRING, SpringContainerRuntime.class);

        JarLoadService jarLoadService = new JarLoadServiceImpl();
        jarLoadService.load(jars);

        Long endTime = System.currentTimeMillis();
        System.out.println("矩阵启动耗时"+(endTime-startTime)+"ms");
        //无限期等待
        while (true) {
            synchronized (LOCK) {
                LOCK.wait(); //等待，直到其它线程调用 lock.notify()
            }
        }
    }
}
